<script type="text/javascript">
$(function(){
	var pg = App.editRegion.ui;
	pg.params = pg.params || { id: '', parent: 'root', path: '/', level: 0 };
	var frm = {
		id: pg.seek('id'),
		name: pg.seek('name'),
		parent: pg.seek('parent'),
		level: pg.seek('level'),
		path: pg.seek('path')
	}
	var setValues = function(o) {
		frm.id.val(o.key);
		frm.name.val(o.title);
		frm.parent.val(o.parent);
		frm.level.val(o.level);
		frm.path.val(o.path);		
	}
	var getValues = function() {
		return {
			id: frm.id.val(),
			name: frm.name.val(),
			parent: frm.parent.val(),
			level: frm.level.val()*1,
			path: frm.path.val()
		}
	}
	function valid(){
		var code = frm.id.val();
		if(!code){
			App.alert(Msg.valid.required,[ Msg.code]);
 			return false;
		}
		var name = frm.name.val();
		if(!name){
			App.alert(Msg.valid.required,[ Msg.name]);
 			return false;
		}
		return true;
	}
	pg.seek("ok").click(function(){
		if(!valid())
			return;
		App.alert('Save is not allowed in this demo.');
//		var p = getValues();
//		var w = App.wait(Msg.info.loading);
//		$.post('region/save.do',p,function(data){
//			var ro = App.eval(data);
//			if(ro.success){
//				App.alert(Msg.saved);
//				pg.dialog("close");
//				if(pg.callback)
//					pg.callback(ro.data);
//			}else{
//				App.alert(App.eval(ro.data),ro.params);
//			}
//			w.remove();
//		});
	}).button();
	pg.seek("cancel").click(function(){
		pg.dialog("close");
	}).button();
	if(pg.params.key)
		frm.id.attr('readonly', 'readonly');
	setValues(pg.params);
	App.setLanguage();
});
</script>
<div class="form">
	<input type="hidden" name="parent" />
	<input type="hidden" name="level" />
	<input type="hidden" name="path" />
	<div class="item">
		<div class="label" style="width: 120px;"><span class="text">Msg.code</span>:</div>
		<input type="text" name="id" style="width: 240px;" />
	</div>
	<div class="item">
		<div class="label" style="width: 120px;"><span class="text">Msg.name</span>:</div>
		<input type="text" name="name" style="width: 240px" />
	</div>
	<div class="msg"></div>
	<div class="bottom">
		<button name="ok"><span class="text">Msg.ok</span></button>
		<button name="cancel"><span class="text">Msg.cancel</span></button>
	</div>
</div>